import { S } from '../s';
import { IPSApplication } from './ipsapplication';
import { IPSApplicationLogic } from './ipsapplication-logic';
import { IPSAppDataEntity } from './dataentity/ipsapp-data-entity';
import { IPSAppUILogic } from './logic/ipsapp-uilogic';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSApplicationLogicImpl
  extends PSModelObjectImpl
  implements IPSApplicationLogic
{
  get eventArg(): string {
    return this.M.eventArg;
  }

  get eventArg2(): string {
    return this.M.eventArg2;
  }

  get eventNames(): string {
    return this.M.eventNames;
  }

  get logicTag(): string {
    return this.M.logicTag;
  }

  get logicType(): string {
    return this.M.logicType;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  protected psappuilogic: IPSAppUILogic;
  getPSAppUILogic(): IPSAppUILogic | null {
    if (this.psappuilogic != null) return this.psappuilogic;
    const value = this.M.getPSAppUILogic;
    if (value == null) {
      return;
    }
    const ipsapplication = this.getParentPSModelObject(
      S._26e,
    ) as IPSApplication;
    if (ipsapplication != null) {
      this.psappuilogic = ipsapplication.findPSAppUILogic(value);
    }
    return this.psappuilogic;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get timer(): number {
    return this.M.timer != null ? this.M.timer : 0;
  }

  get triggerType():
    | 'TIMER'
    | 'CTRLEVENT'
    | 'VIEWEVENT'
    | 'APPEVENT'
    | 'ITEMVISIBLE'
    | 'ITEMENABLE'
    | 'ITEMBLANK'
    | 'ITEMDYNACLASS'
    | 'RENDER'
    | 'ATTRIBUTE'
    | 'CUSTOM'
    | 'VUE_DIRECTIVE' {
    return this.M.triggerType || 'APPEVENT';
  }
  get cls(): string {
    return 'PSApplicationLogicImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._38f) return true;
    return super.instanceof(cls);
  }
}
